function saveStorage(id) {
    var data = document.getElementById(id).value;
    var time = new Date().getTime();
    localStorage.setItem(time, data);
    console.log("数据已保存");
    loadStorage('msg');
}

function loadStorage(id) {
    var result = '<table width="500px">';
    for (var i = 0; i < localStorage.length; i++) {
        var kes = localStorage.key(i);
        var value = localStorage.getItem(kes);
        var date = new Date();
        date.setTime(kes);
        var datestr = date.toGMTString();
        result += '<tr>' + value + '</tr><br><tr float="right">' + datestr + '</tr><br>'
    }
    result += '</table>';
    var target = document.getElementById(id);
    target.innerHTML = result;
}

function clearStorage() {
    localStorage.clear();
    console.log("清除完毕");
}